<template>
  <div class="container">
    <navBar :navBar="navBar"></navBar>
    <div class="content">
      <div
        v-for="(item, index) in newsList"
        :key="index"
        class="itemBox"
        @click="goOther(item.help_id)"
      >
        <p class="title">{{ item.title }}</p>
        <p class="time">{{ formatTime(item.addtime, "yyyy-MM-dd HH:mm:ss") }}</p>
      </div>
    </div>
	<tabBar :active="1"></tabBar>
  </div>
</template>

<script>
	import tabBar from "@/components/tabBar.vue";
import {formatTime} from '@/utils/tools.js'
import navBar from "@/components/navBar.vue";
export default {
  name: "news",
  components: { navBar,tabBar },
  data() {
    return {
      navBar: {
        back: true,
        title: this.$t("公告资讯"),
        close: false,
        btn: "",
      },
      newsList: [],
    };
  },

  mounted() {
    this.getList();
  },

  methods: {
    formatTime,
    // 获取列表
    getList() {
      let data = {
        type: 2,
        language: String(this.$i18n.locale).toUpperCase()
      };
      $postAxios(api.getNotify, data, (res) => {
        if (res.code == 0) {
          this.newsList = res.data;
        } else {
          this.$toast(this.$(res.msg));
        }
      });
    },
    // 跳转页面
    goOther(id) {
      this.$router.push("/newsDetail?id=" + id);
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background-color: #f7f6fb;
  .content {
    padding: 10px 15px 15px;
    width: 100%;
    position: absolute;
    left: 0;
    top: 40px;
    bottom: 0;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    .itemBox {
      margin-bottom: 10px;
      padding: 15px;
      color: #333;
      background-color: #fff;
      border-radius: 5px;
      .title {
        margin-bottom: 8px;
        font-size: 18px;
      }
      .time {
        margin-bottom: 10px;
        padding-bottom: 10px;
        font-size: 12px;
        line-height: 1;
        border-bottom: 1px solid #c8c7cc;
      }
    }
  }
}
</style>